package com.cloudsigns.factorymanager2.project.presenter;

import android.os.Handler;

import com.cloudsigns.factorymanager2.project.iview.IProductOrderDeleteView;
import com.cloudsigns.factorymanager2.project.model.IProductOrderDeleteModel;
import com.cloudsigns.factorymanager2.project.model.ProductOrderDeleteModel;

public class ProductOrderDeletePresenter {
    private IProductOrderDeleteView view;
    private IProductOrderDeleteModel model;
    private Handler mHandler = new Handler();

    public ProductOrderDeletePresenter(IProductOrderDeleteView iView) {
        this.view = iView;
        this.model = new ProductOrderDeleteModel();
    }

    public void productOrderDelete() {
        model.deleteProductOrder(view.getOrderId(), new ProductOrderDeleteModel.OnDeleteProductOrderListener() {
            @Override
            public void deleteSuccessed() {
                mHandler.post(new Runnable() {
                    @Override
                    public void run() {
                        view.deleteSunccessed();
                        view.hideLoading();
                    }
                });
            }

            @Override
            public void deleteFailed(final String desc) {
                mHandler.post(new Runnable() {
                    @Override
                    public void run() {
                        view.deleteFailed(desc);
                        view.hideLoading();
                    }
                });
            }
        });
    }
}
